rtc23 2.2.1
Loading...
Searching...
No Matches
rtc23


RTC 23 Click

RTC 23 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Jun 2024.
  • Type : SPI type

Software Support

Example Description

This example demonstrates the use of RTC 23 Click board by reading and displaying the time and date values.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.RTC23

Example Key Functions

  • rtc23_cfg_setup Config Object Initialization function.
    void rtc23_cfg_setup(rtc23_cfg_t *cfg)
    RTC 23 configuration object setup function.
    RTC 23 Click configuration object.
    Definition rtc23.h:215
  • rtc23_init Initialization function.
    err_t rtc23_init ( rtc23_t *ctx, rtc23_cfg_t *cfg );
    err_t rtc23_init(rtc23_t *ctx, rtc23_cfg_t *cfg)
    RTC 23 initialization function.
    RTC 23 Click context object.
    Definition rtc23.h:195
  • rtc23_set_time This function sets the starting time values - second 100th, second, minute and hour.
    err_t rtc23_set_time ( rtc23_t *ctx, rtc23_time_t *time );
    err_t rtc23_set_time(rtc23_t *ctx, rtc23_time_t *time)
    RTC 23 set time function.
    RTC 23 Click time object.
    Definition rtc23.h:240
  • rtc23_read_time This function reads the current time values - second 100th, second, minute and hour.
    err_t rtc23_read_time ( rtc23_t *ctx, rtc23_time_t *time );
    err_t rtc23_read_time(rtc23_t *ctx, rtc23_time_t *time)
    RTC 23 read time function.
  • rtc23_set_date This function sets the starting date values - day of week, day, month and year.
    err_t rtc23_set_date ( rtc23_t *ctx, rtc23_date_t *date );
    err_t rtc23_set_date(rtc23_t *ctx, rtc23_date_t *date)
    RTC 23 set date function.
    RTC 23 Click date object.
    Definition rtc23.h:254

Application Init

Initializes the driver, checks the communication, and sets the starting time and date.

void application_init ( void )
{
log_cfg_t log_cfg;
rtc23_cfg_t rtc23_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
rtc23_cfg_setup( &rtc23_cfg );
if ( SPI_MASTER_ERROR == rtc23_init( &rtc23, &rtc23_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Check communication." );
for ( ; ; );
}
time.hour = 23;
time.minute = 59;
time.second = 50;
time.second_100th = 0;
if ( RTC23_OK == rtc23_set_time ( &rtc23, &time ) )
{
log_printf( &logger, " Set time: %.2u:%.2u:%.2u\r\n",
( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
}
date.day_of_week = RTC23_TUESDAY;
date.day = 31;
date.month = 12;
date.year = 24;
if ( RTC23_OK == rtc23_set_date ( &rtc23, &date ) )
{
log_printf( &logger, " Set date: %s, %.2u.%.2u.20%.2u.\r\n",
rtc23_get_day_of_week_name ( date.day_of_week ),
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
}
Delay_ms ( 100 );
log_info( &logger, " Application Task " );
}
#define RTC23_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition rtc23.h:178
#define RTC23_TUESDAY
Definition rtc23.h:138
err_t rtc23_check_communication(rtc23_t *ctx)
RTC 23 check communication function.
void application_init(void)
Definition main.c:45
#define MIKROBUS_POSITION_RTC23
Definition main.c:26
@ RTC23_ERROR
Definition rtc23.h:269
@ RTC23_OK
Definition rtc23.h:268

Application Task

Reads and displays on the USB UART the current time and date values once per second.

void application_task ( void )
{
if ( RTC23_OK == rtc23_read_time ( &rtc23, &time ) )
{
log_printf( &logger, " Time: %.2u:%.2u:%.2u\r\n",
( uint16_t ) time.hour, ( uint16_t ) time.minute, ( uint16_t ) time.second );
}
if ( RTC23_OK == rtc23_read_date ( &rtc23, &date ) )
{
log_printf( &logger, " Date: %s, %.2u.%.2u.20%.2u.\r\n",
rtc23_get_day_of_week_name ( date.day_of_week ),
( uint16_t ) date.day, ( uint16_t ) date.month, ( uint16_t ) date.year );
}
Delay_ms ( 1000 );
}
err_t rtc23_read_date(rtc23_t *ctx, rtc23_date_t *date)
RTC 23 read date function.
void application_task(void)
Definition main.c:101

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.